/* eslint-disable */
import Vue from 'vue'
import Vuex from 'vuex'
import api from '../API/index'
import router from '../router/index'

const defaultAvatar = new Image('../../static/img/default-avatar.png')
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    order: {} //{'good-1':3}
  },
  mutations: {
    initOrder(state, data) {
      state.order = data
    },
    changeNumOfGoodOrdered(state, data) {
      const { type, goodId } = data
      const change = type === 'add' ? 1 : -1
      const newOrder = state.order
      if (newOrder[goodId]) {
        newOrder[goodId] += change
      } else {
        newOrder[goodId] = 1
      }
      state.order = newOrder
    }
  },
  actions: {}
})

export default store
